#include <stdio.h>
#include <assert.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>

typedef int int32;

static void echo(FILE* out,int32 value)
	{
	int i;
	char* p=(char*)&value;
	printf("%d\t:\t",value);
	for(i=0;i< sizeof(int32);++i)
		{
		printf("%d ",p[i]);
		}
	printf("\n");
	fwrite(&value,sizeof(int32),1,out);
	}

int main(int argc,char** argv)
{
int optind=1;
FILE* out= fopen("int32.bin","wb");
fprintf(stderr,"sizeof(int32)=%d\n",sizeof(int32));
assert(sizeof(int32)*8==32);
if(out==NULL)
	{
	fprintf(stderr,"Cannot write file.\n");
	return -1;
	}
echo(out,0);
echo(out,100663296);
echo(out,100728832);
echo(out,100663295);
echo(out,INT_MAX);
for(optind=1;optind< argc;++optind)
{
char *p2;
int32 value= strtol(argv[optind],&p2,0);
assert(*p2==0);
echo(out,value);
}
fflush(out);
fclose(out);
return 0;
}
